package com.anyisn.anyflickr.shell
{
	import com.anyisn.anyflickr.shell.controller.*;
	import com.anyisn.anyflickr.shell.controller.slide.*;
	import com.anyisn.anyflickr.shell.controller.tile.*;
	import com.anyisn.puremvc.as3.multicore.patterns.command.ErrorCommand;
	
	import org.puremvc.as3.multicore.patterns.facade.Facade;
	import org.puremvc.as3.multicore.utilities.air.xmldb.controller.PersistDataCommand;

	public class ShellFacade extends Facade
	{
		public static const STARTUP:String 	= 'startup';
		public static const SHUTDOWN:String = 'shutdown';
		public static const ERROR:String = 'error';
		
		// photo info
		public static const SHOW_PHOTO_INFO_WINDOW:String = 'showPhotoInfoWindow';
		public static const CLOSE_PHOTO_INFO_WINDOW:String = 'closePhotoInfoWindow';
		public static const TO_CLOSE_PHOTO_INFO_WINDOW:String = 'toClosePhotoInfoWindow';
		public static const CHANGE_PHOTO_IN_PHOTO_INFO_WINDOW:String = 'changePhotoInPhotoInfoWindow';
		
		// photos slide
		public static const SHOW_PHOTOS_SLIDE_WINDOW:String = 'showPhotosSlideWindow';
		public static const CLOSE_PHOTOS_SLIDE_WINDOW:String = 'closePhotosSlideWindow';
		
		// slide
		public static const STARTED:String				= "yisn.widgets.PhotosSlide.started";
		public static const PAUSED:String				= "yisn.widgets.PhotosSlide.paused";
		public static const CONTINUED:String			= "yisn.widgets.PhotosSlide.continued";
		public static const ENDED:String				= "yisn.widgets.PhotosSlide.ended";
		public static const PAUSE:String				= "yisn.widgets.PhotosSlide.pause";
		public static const CONTINUE:String				= "yisn.widgets.PhotosSlide.continue";
		public static const PHOTO_CHANGE:String			= "yisn.widgets.PhotosSlide.photo_change";

		// thumbslist page control
		public static const THUMBS_CHANGE_PAGE:String		= 'thumbsChangePage';
		public static const THUMBS_GET_PREVIOUS_PAGE:String	= 'thumbsGetPreviousPage';
		
		// Photos Menu Options
		public static const TILE_PHOTOS_SEARCH:String 				= 'tilePhotosSearch';	
		public static const TILE_INTERESTINGNESS_GET_LIST:String 		= 'tileInterestingnessGetList';
		public static const TILE_FAVORITES_GET_LIST:String			= 'tileFavoritesGetList';
		public static const TILE_PEOPLE_GET_PUBLIC_PHOTOS:String 		= 'tilePeopleGetPublicPhotos';
		
		public static const TILE_PHOTOS_SEARCH_SUCCESS:String				= 'tilePhotosSearchSuccess';
		public static const TILE_PHOTOS_SEARCH_FAILED:String 				= 'tilePhotosSearchFailed';
		public static const TILE_INTERESTINGNESS_GET_LIST_SUCCESS:String 	= 'tileInterestingnessGetListSuccess';
		public static const TILE_INTERESTINGNESS_GET_LIST_FAILED:String 	= 'tileInterestingnessGetListFailed';
		public static const TILE_FAVORITES_GET_LIST_SUCCESS:String 		= 'tileFavoritesGetListSuccess';
		public static const TILE_FAVORITES_GET_LIST_FAILED:String 			= 'tileFavoritesGetListFailed';
		public static const TILE_PEOPLE_GET_PUBLIC_PHOTOS_SUCCESS:String 	= 'tilePeopleGetPublicPhotosSuccess';
		public static const TILE_PEOPLE_GET_PUBLIC_PHOTOS_FAILED:String 	= 'tilePeopleGetPublicPhotosFailed';
		
		
		public static const SLIDE_PHOTOS_SEARCH:String 				= 'slidePhotosSearch';	
		public static const SLIDE_INTERESTINGNESS_GET_LIST:String 	= 'slideInterestingnessGetList';
		public static const SLIDE_FAVORITES_GET_LIST:String			= 'slideFavoritesGetList';
		public static const SLIDE_PEOPLE_GET_PUBLIC_PHOTOS:String 	= 'slidePeopleGetPublicPhotos';
		
		public static const SLIDE_PHOTOS_SEARCH_SUCCESS:String				= 'slidePhotosSearchSuccess';
		public static const SLIDE_PHOTOS_SEARCH_FAILED:String 				= 'slidePhotosSearchFailed';
		public static const SLIDE_INTERESTINGNESS_GET_LIST_SUCCESS:String 	= 'slideInterestingnessGetListSuccess';
		public static const SLIDE_INTERESTINGNESS_GET_LIST_FAILED:String 	= 'slideInterestingnessGetListFailed';
		public static const SLIDE_FAVORITES_GET_LIST_SUCCESS:String 		= 'slideFavoritesGetListSuccess';
		public static const SLIDE_FAVORITES_GET_LIST_FAILED:String 		= 'slideFavoritesGetListFailed';
		public static const SLIDE_PEOPLE_GET_PUBLIC_PHOTOS_SUCCESS:String	= 'slidePeopleGetPublicPhotosSuccess';
		public static const SLIDE_PEOPLE_GET_PUBLIC_PHOTOS_FAILED:String 	= 'slidePeopleGetPublicPhotosFailed';
		
		// PHOTOS
		public static const PHOTOS_GET_SIZES_SUCCESS:String	= 'photosGetSizesSuccess';
		public static const PHOTOS_GET_SIZES_FAILED:String	= 'photosGetSizesFailed';
		
		// PEOPLE
		public static const SHOW_PEOPLE_WIN:String = 'showPeopleWin';
		
		public static const PEOPLE_GET_INFO:String = 'peopleGetInfo';
		public static const PEOPLE_GET_INFO_SUCCESS:String = 'peopleGetInfoSuccess';
		public static const PEOPLE_GET_INFO_FAILED:String = 'peopleGetInfoFailed';
		
		public static const PERSON_ADD_PREPARE:String = 'personAddPrepare';
		public static const PERSON_DELETE:String = 'personDelete';
		public static const PERSON_GET_LIST:String = 'personGetList';
		public static const PERSON_GET_LIST_SUCCESS:String = 'personGetListSuccess';
		public static const PERSON_FILTER_BY_TAG:String = 'personFilterByTag';
		public static const PERSON_FILTER_BY_TAG_SUCCESS:String = 'personFilterByTagSuccess';
		public static const TAGS_GET_LIST:String = 'tagsGetList';
		public static const TAGS_GET_LIST_FOR_PEOPLE_WINDOW_SUCCESS:String = 'tagsGetListForPeopleWindowSuccess';
		public static const TAGS_GET_LIST_FOR_PERSON_TW_SUCCESS:String = 'tagsGetListForPersonTWSuccess';
		
		public static const TAG_ADD:String = 'tagAdd';
		public static const TAG_PUSH:String = 'tagPush';
		public static const TAG_REMOVE:String = 'tagRemove';
		public static const TAG_DELETE:String = 'tagDelete';

		// AUTH
		public static const LOGIN:String = 'login';
		public static const LOGOUT:String = 'logout';
		public static const LOGIN_SUCCESS:String = 'loginSuccess';
		public static const LOGIN_FAILED:String = 'loginFailed';
		public static const LOGOUT_SUCCESS:String = 'logoutSuccess';
		
		// FAVORITES
		public static const FAVORITES_ADD:String = 'favoritesAdd';
		public static const FAVORITES_ADD_SUCCESS:String = 'favoritesAddSuccess';
		public static const FAVORITES_ADD_FAILED:String = 'favoritesAddFailed';
		public static const FAVORITES_REMOVE:String = 'favoritesRemove';
		public static const FAVORITES_REMOVE_SUCCESS:String = 'favoritesRemoveSuccess';
		public static const FAVORITES_REMOVE_FAILED:String = 'favoritesRemoveFailed';
		
		// TEST
		public static const ONLINE:String = 'online';
		public static const OFFLINE:String = 'offline';
		public static const TEST_ONLINE:String = 'testOnline';
		
		// Photo Download
		public static const PHOTO_DOWNLOAD:String = 'photoDownload';
		public static const PHOTO_DOWNLOAD_PROGRESS:String 	= 'photoDownloadProgress';
		public static const PHOTO_DOWNLOAD_COMPLETE:String 	= 'photoDownloadComplete';
		public static const PHOTO_BATCH_DOWNLOAD:String 	= 'photoBatchDownload';
		
		// Photo Load
		public static const TILE_PHOTO_LOAD_SUCCESS:String = 'tilePhotoLoadSuccess';
		public static const PHOTO_PREPARE_DOWNLOAD:String = 'photoPrepareDownload';
		public static const PHOTO_LOAD:String = 'photoLoad';
		public static const PHOTO_LOAD_CANCEL:String = 'photoLoadCancel';
		public static const PHOTO_LOAD_CANCELED:String = 'photoLoadCanceled';
		public static const PHOTO_LOAD_OPEN:String = 'photoLoadOpen';
		public static const PHOTO_LOAD_PROGRESS:String = 'photoLoadProgress';
		public static const PHOTO_LOAD_COMPLETE:String = 'photoLoadComplete';
		
		// Settings
		public static const SETTINGS_SAVE:String = 'settingsSave';
		
		// About
		public static const CHECK_FOR_UPDATE:String = 'checkForUpdate';
		
		// navigateToURL
		public static const NAVIGATE_TO_PROFILE:String = 'navigateToProfile';
		public static const NAVIGATE_TO_PHOTOSTREAM:String = 'navigateToPhotostream';
		public static const NAVIGATE_TO_PHOTOPAGE:String = 'navigateToPhotopage';
		
		// Google Translate
		public static const GOOGLE_TRANSLATE_GET:String = 'googleTranslateGet';
		public static const GOOGLE_TRANSLATE_RESULT:String = 'googleTranslateResult';
		
		public function ShellFacade( key:String )
		{
			super(key);
		}
		
		public static function getInstance(key:String):ShellFacade {
            if (instanceMap[key] == null)
				instanceMap[key] = new ShellFacade(key);
            return instanceMap[key] as ShellFacade;
		}
		
		// 初始化Controller，注册全局Command
		override protected function initializeController():void {
			super.initializeController();
			registerCommand(STARTUP, StartupCommand);
			registerCommand(SHUTDOWN, ShutdownCommand);
			registerCommand(PersistDataCommand.NAME, PersistDataCommand);
			
			registerCommand(ERROR, ErrorCommand);
			
			// list
			registerCommand(TILE_PHOTOS_SEARCH, TilePhotosSearchCommand);
			registerCommand(TILE_INTERESTINGNESS_GET_LIST, TileInterestingnessGetListCommand);
			registerCommand(TILE_PEOPLE_GET_PUBLIC_PHOTOS, TilePeopleGetPublicPhotosCommand);
			registerCommand(TILE_FAVORITES_GET_LIST, TileFavoritesGetListCommand);
			registerCommand(THUMBS_CHANGE_PAGE, TilePageChangeCommand);
			registerCommand(THUMBS_GET_PREVIOUS_PAGE, TileGetPreviousCommand);
			registerCommand(TILE_PHOTO_LOAD_SUCCESS, PhotoInfoWindowOpenCommand);
			
			// slide
			registerCommand(SLIDE_PHOTOS_SEARCH, SlidePhotosSearchCommand);
			registerCommand(SLIDE_INTERESTINGNESS_GET_LIST, SlideInterestingnessGetListCommand);
			registerCommand(SLIDE_PEOPLE_GET_PUBLIC_PHOTOS, SlidePeopleGetPublicPhotosCommand);
			registerCommand(SLIDE_FAVORITES_GET_LIST, SlideFavoritesGetListCommand);
			
			registerCommand(SLIDE_PHOTOS_SEARCH_SUCCESS, PhotosSlideWindowOpenCommand);
			registerCommand(SLIDE_INTERESTINGNESS_GET_LIST_SUCCESS, PhotosSlideWindowOpenCommand);
			registerCommand(SLIDE_PEOPLE_GET_PUBLIC_PHOTOS_SUCCESS, PhotosSlideWindowOpenCommand);
			registerCommand(SLIDE_FAVORITES_GET_LIST_SUCCESS, PhotosSlideWindowOpenCommand);
			
			// download
			registerCommand(PHOTO_PREPARE_DOWNLOAD, PhotoPrepareDownloadCommand);
			registerCommand(PHOTO_DOWNLOAD, PhotoDownloadCommand);
			registerCommand(PHOTO_BATCH_DOWNLOAD, PhotoBatchDownloadCommand);
			
			// Person
			registerCommand(PERSON_DELETE, PersonDeleteCommand);
			registerCommand(PEOPLE_GET_INFO, PeopleGetInfoCommand);
			registerCommand(PERSON_ADD_PREPARE, PeopleGetInfoCommand);
			registerCommand(PERSON_GET_LIST, PersonGetListCommand);
			registerCommand(PERSON_FILTER_BY_TAG, PersonFilterByTagCommand);
			registerCommand(TAGS_GET_LIST, TagsGetListCommand);
			registerCommand(TAG_ADD, TagAddCommand);
			registerCommand(TAG_PUSH, TagPushCommand);
			registerCommand(TAG_REMOVE, TagRemoveCommand);
			registerCommand(TAG_DELETE, TagDeleteCommand);
			
			// Auth
			registerCommand(LOGIN, LoginCommand);
			registerCommand(LOGOUT, LogoutCommand);
			registerCommand(LOGIN_SUCCESS, LoginSuccessCommand);
			
			// FAVORITES
			registerCommand(FAVORITES_ADD, FavoritesAddCommand);
			registerCommand(FAVORITES_REMOVE, FavoritesRemoveCommand);
			
			// Settings
			registerCommand(SETTINGS_SAVE, SettingsSaveCommand);
			
			// About
			registerCommand(CHECK_FOR_UPDATE, CheckForUpdateCommand);
			
			// Test
			registerCommand(ONLINE, OnlineCommand);
			registerCommand(TEST_ONLINE, TestOnlineCommand);
			
			// Translate
			registerCommand(GOOGLE_TRANSLATE_GET, GoogleTranslateCommand);
		}
		
		public function startup(app:AnyFlickr):void {
			sendNotification(STARTUP, app);
			sendNotification(TEST_ONLINE);
		}
	}
}